<?php
$this->breadcrumbs = array(
    Yii::t('app', 'Manage Users'),
);

$this->menu = array(
    array('label' => Yii::t('app', 'Manage Users'), 'url' => array('admin')),
    array('label' => Yii::t('app', 'Create Users'), 'url' => array('create')),
);

//Yii::app()->clientScript->registerScript('search', "
//$('.search-button').click(function(){
//	$('.search-form').toggle();
//	return false;
//});
//$('.search-form form').submit(function(){
//	$.fn.yiiGridView.update('users-grid', {
//		data: $(this).serialize()
//	});
//	return false;
//});
//");
?>

<h1><?php echo Yii::t('app', 'Manage Web Users') ?></h1>

<p>
    <!--  You may optionally enter a comparison operator (&lt;, &lt;=, &gt;, &gt;=, &lt;&gt; or =) at the beginning of each of your search values to specify how the comparison should be done.-->
</p>

<?php //echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?>
<!--<div class="search-form">
<?php
//    $this->renderPartial('_search', array(
//        'model' => $model,
//    ));
?>
</div> search-form -->

<?php
$with = array(
//    'userHasRoles' => array(
//        'on' => 'userHasRoles.users_id=t.id',
//        'condition' => "userHasRoles.users_id=t.id AND userHasRoles.roles_id=".Roles::WEBUSER,
//        'together' => true,
//        'joinType' => 'LEFT JOIN',
//    )
);


$criteria = array('with' => $with);

$modelData = new CActiveDataProvider('Users', array('criteria' => $criteria,
            'sort' => array(
                'defaultOrder' => 't.username',
            ),));

//pr($modelData->getData());


$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'users-grid',
    'dataProvider' => $modelData,
    'filter' => $model,
    'columns' => array(
        //   'id',
        'username',
        //  'profiles.firstname',
        array(
            'header' => 'First Name',
            'type' => 'html',
            'value' => 'isset($data->profiles[0]) ? CHtml::encode($data->profiles[0]->firstname) : ""',
        ),
        array(
            'header' => 'Last Name',
            'type' => 'html',
            'value' => 'isset($data->profiles[0]) ? CHtml::encode($data->profiles[0]->lastname) : ""',
        ),
        // 'profiles.lastname',
        /*
          'superuser',
          array(
          'name' => 'status',
          'value' => '($data->status === 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',
          'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
          ),
         */
        array(
            'class' => 'CButtonColumn',
        ),
    ),
));
?>